package com.example.demo.entity;

import java.util.ArrayList;
import java.util.List;

public class User {

    static List<User> users;
    static {
        users = new ArrayList<>();
        users.add(new User(1,"tom"));
        users.add(new User(2,"jom"));
        users.add(new User(3,"hog"));
        users.add(new User(4,"Make"));
        users.add(new User(5,"Super"));
        users.add(new User(6,"haha"));
    }

    private Integer id;
    private String name;

    public User() {
    }

    public User(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static User findById(Integer id) {
        for (User u:users) {
            if (u.getId().equals(id)){
                return u;
            }
        }
        return null;
    }
}
